package com.zhuojy.equity.mall.admin.service.car;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.po.car.TCarPurchasePO;
import com.zhuojy.equity.mall.admin.common.pojo.ResultEntity;
import com.zhuojy.equity.mall.admin.dal.mapper.car.TCarPurchaseMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author xrz
 * @version 1.0
 * @description:TODO
 * @date 2024/4/8 19:51
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TCarPurchaseService extends ServiceImpl<TCarPurchaseMapper, TCarPurchasePO> {
    public ResultEntity findCarcheerPagination(TCarPurchasePO tCarPurchasePO, Integer pageSize, Integer pageNum) {
        Page<TCarPurchasePO> page = new Page<>(pageNum, pageSize);
        IPage<TCarPurchasePO>  tCarMaintainPOIPage = this.baseMapper.findCarcheerPagination(tCarPurchasePO, page);
        return ResultEntity.OK(tCarMaintainPOIPage);
    }

    public ResultEntity delMaintain(Integer id) {
        this.baseMapper.deleteById(id);
        return ResultEntity.OK("操作成功");
    }

    public ResultEntity addMaintain(TCarPurchasePO tCarMaintainPO) {
        this.baseMapper.insert(tCarMaintainPO);
        return ResultEntity.OK("添加成功");
    }

    public ResultEntity echoMaintain(Integer id) {
        TCarPurchasePO tCarMaintainPO = this.baseMapper.selectById(id);
        return ResultEntity.OK(tCarMaintainPO);
    }

    public ResultEntity upMaintain(TCarPurchasePO tCarMaintainPO) {
        this.baseMapper.updateById(tCarMaintainPO);
        return ResultEntity.OK("修改成功");
    }
}
